package com.cqjtu.checkbook;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

/**
 * Created by Administrator on 2016/10/29 0029.
 */
public class Student {
    private Integer id;
    private String sno;
    private String  sname;
    private String banji;
    private String state;
    private Bitmap bitmap;
    private Integer zaiqin;
    private Integer chidao;
    private Integer zaotui;
    private Integer kuangke;
    private Integer bingjia;
    private static MyDBHelper dbHelper  = new MyDBHelper(MyApplication.getContext(),"CheckBook.db",null,1);
    private static SQLiteDatabase db = dbHelper.getWritableDatabase();

    public Student(Integer id, String sno, String sname, String banji, String state, Bitmap bitmap,
                   Integer zaiqin,Integer chidao,Integer zaotui,Integer kuangke,Integer bingjia){
        this.id = id;
        this.sno = sno;
        this.sname = sname;
        this.banji = banji;
        this.bitmap = bitmap;
        Cursor cursor = db.query("CheckBook",null,null,null,null,null,null);
       String s = "默认";
        if(cursor.moveToFirst()){
            do{
                int dt = cursor.getInt(cursor.getColumnIndex("id"));
                if(dt==this.getId()){
                    s = cursor.getString(cursor.getColumnIndex("State"));
                    byte[] in=cursor.getBlob(cursor.getColumnIndex("img"));
                    bitmap = BitmapFactory.decodeByteArray(in,0,in.length);
                    this.zaiqin = cursor.getInt(cursor.getColumnIndex("zaiqin"));
                    this.chidao = cursor.getInt(cursor.getColumnIndex("chidao"));
                    this.zaotui = cursor.getInt(cursor.getColumnIndex("zaotui"));
                    this.kuangke = cursor.getInt(cursor.getColumnIndex("kuangke"));
                    this.bingjia = cursor.getInt(cursor.getColumnIndex("bingjia"));
                    break;
                }

            }while(cursor.moveToNext());
        }
        this.state =s;
        this.bitmap = bitmap;
    }

    public Integer getId() {
        return id;
    }

    public String getSno() {
        return sno;
    }

    public String getBanji() {
        return banji;
    }

    public String getSname() {
        return sname;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Bitmap getBitmap() {
        return bitmap;
    }

    public void setBitmap(Bitmap bitmap) {
        this.bitmap = bitmap;
    }

    public Integer getBingjia() {
        return bingjia;
    }

    public Integer getChidao() {
        return chidao;
    }

    public Integer getKuangke() {
        return kuangke;
    }

    public Integer getZaiqin() {
        return zaiqin;
    }

    public Integer getZaotui() {
        return zaotui;
    }

    public void setBanji(String banji) {
        this.banji = banji;
    }

    public void setBingjia(Integer bingjia) {
        this.bingjia = bingjia;
    }

    public void setChidao(Integer chidao) {
        this.chidao = chidao;
    }

    public void setKuangke(Integer kuangke) {
        this.kuangke = kuangke;
    }

    public void setZaiqin(Integer zaiqin) {
        this.zaiqin = zaiqin;
    }

    public void setZaotui(Integer zaotui) {
        this.zaotui = zaotui;
    }
}
